package com.zqwh.yj.sdk.utils.httpRequest;


import com.zqwh.yj.sdk.utils.httpRequest.beans.HttpResult3;
import com.zqwh.yj.sdk.utils.httpRequest.beans.HttpResult4;

import rx.functions.Func1;


/**
 * Created by eason.yang on 2017/7/10.
 * 用来统一处理Http的resultCode,并将HttpResult的Data部分剥离出来返回给subscriber
 *
 * @param <T> Subscriber真正需要的数据类型，也就是Data部分的数据类型
 */
public class HttpResultFunc4<T> implements Func1<HttpResult4<T>, T> {
    @Override
    public T call(HttpResult4<T> httpResult) {
        if (httpResult.getReturnCode() != 0) {
            throw new ApiException(httpResult.getReturnMsg());
        }
        return httpResult.getResult();
    }
}
